import React, { useState } from 'react'
import './App.css'
import Header from './components/Header'
import List from './components/List'
import Footer from './components/Footer'
import { nanoid } from 'nanoid'

export default function App() {

  const [todoList, setTodoList] = useState([
    { id: nanoid(), todo: "唱", done: false },
    { id: nanoid(), todo: "跳", done: false },
    { id: nanoid(), todo: "rap", done: false },
  ])
  // console.log(todoList);
  //通常是给子组件传一个函数,在子组件中调用这个函数,参数传求出来的值,在父组件中的这个函数中添加state
  return (
    <div className="todo-container">
      <div className="todo-wrap">
        <Header setTodoList={setTodoList} todoList={todoList} />
        {/* 如果{...todoList},这样传是把这个数组展开传的,传过去的是一个对象,无法遍历 */}
        <List todoList={todoList} />
        <Footer />
      </div>
    </div>
  )
}
